import { create } from "zustand";
import axios from "axios";
import { devtools } from "zustand/middleware";
const URL = "http://geek.itheima.net/v1_0/channels";

export const createChannelStore = create(
  devtools((set) => {
    return {
      channelList: [],
      // 异步方法
      fetchChannelList: async () => {
        const res = await axios.get(URL);
        set({ channelList: res.data.data.channels });
      }
    };
  })
);
